"use strict";BX.namespace("BX.Rest.Marketplace.Install");BX.Rest.Marketplace.Install={init:function(e){e=typeof e==="object"?e:{};this.code=e.CODE||false;this.version=e.VERSION||false;this.checkHash=e.CHECK_HASH||false;this.installHash=e.INSTALL_HASH||false;this.from=e.FROM||false;this.iframe=e.IFRAME||false;this.redirectPriority=e.REDIRECT_PRIORITY||false;this.formNode=BX("restMarketAppInstallForm");this.buttonInstallNode=BX.findChildByClassName(this.formNode,"rest-btn-start-install");this.buttonCloseNode=BX.findChildByClassName(this.formNode,"rest-btn-close-install");BX.bind(this.formNode,"submit",this.onSubmitForm.bind(this));BX.bind(this.buttonCloseNode,"click",this.onClickClose.bind(this))},onClickClose:function(e){e.preventDefault();if(!!this.iframe){BX.SidePanel.Instance.close()}},onSubmitForm:function(e){e.preventDefault();if(BX("mp_tos_license")&&!BX("mp_tos_license").checked){BX("rest_mp_install_error").innerHTML=BX.message("REST_MARKETPLACE_INSTALL_TOS_ERROR");BX.show(BX("rest_mp_install_error"));return}if(BX("mp_detail_license")&&!BX("mp_detail_license").checked||BX("mp_detail_confidentiality")&&!BX("mp_detail_confidentiality").checked){BX("rest_mp_install_error").innerHTML=BX.message("REST_MARKETPLACE_INSTALL_LICENSE_ERROR");BX.show(BX("rest_mp_install_error"));return}if(BX.hasClass(this.buttonInstallNode,"popup-window-button-wait")){return}BX.addClass(this.buttonInstallNode,"popup-window-button-wait");var t={code:this.code};if(!!this.version){t.version=this.version}if(!!this.checkHash){t.check_hash=this.checkHash;t.install_hash=this.installHash}if(!!this.from){t.from=this.from}BX.ajax.runAction("rest.application.install",{data:t}).then(function(e){var t=!!e.data?e.data:e;if(!!t.error){if(!!t.helperCode&&t.helperCode!==""){top.BX.UI.InfoHelper.show(t.helperCode)}else{BX("rest_mp_install_error").innerHTML='<div class="ui-alert-message">'+t.error+(!!t.error_description?"<br />"+t.error_description:"")+"</div>";BX.show(BX("rest_mp_install_error"))}}else if(!!t.redirect&&this.redirectPriority===true){top.location.href=t.redirect}else if(!this.iframe){if(!!t.redirect){top.location.href=t.redirect}else{top.location.href=BX.util.remove_url_param(top.location.href,["install"])}}else{if(t.installed){var i={};top.BX.onCustomEvent(top,"Rest:AppLayout:ApplicationInstall",[true,i],false)}if(!!t.open){BX.SidePanel.Instance.reload();top.BX.rest.AppLayout.openApplication(t.id,{})}else{BX.SidePanel.Instance.reload()}}}.bind(this))},initHelper:function(e){if(!window.BX.UI.InfoHelper.isInited()){window.BX.UI.InfoHelper.init({frameUrlTemplate:e.frameUrlTemplate});window.BX.UI.InfoHelper.frameNode=BX(e.iframeId)}BX.bind(window,"message",BX.proxy((function(e){if(!!e.origin&&e.origin.indexOf("bitrix")===-1){return}if(!e.data||typeof e.data!=="object"){return}if(e.data.action==="reloadParent"){var t=BX.SidePanel.Instance.getTopSlider();if(!!t){t.reload()}else{window.location.reload()}}})))}};
//# sourceMappingURL=script.map.js